-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: properly handle multi-line commands in quotes #9064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Fix parseCommand to preserve newlines within quoted strings instead of incorrectly splitting them - Add UI filtering to exclude multi-line patterns from command pattern selector - Multi-line git commit messages now work correctly for auto-approval validation - UI shows clean patterns like 'git' and 'git commit' instead of unwieldy full commit text - Add comprehensive tests for multi-line command handling - Much simpler approach than placeholder substitution in PR #8792 Fixes the issue where multi-line git commit messages were being split into separate commands and causing cluttered UI in the auto-approved commands list.
The previous test expectations were using escaped \n strings, but template literals preserve actual whitespace. Updated tests to use regex patterns to verify the correct multi-line behavior while being flexible about exact whitespace formatting.
Review complete. No issues found. The PR correctly fixes multi-line command parsing by protecting quoted strings before splitting on newlines, and filters multi-line patterns from the UI selector. The implementation is sound, tests are comprehensive, and no bugs were identified. Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request. |
| }) | ||
|
|
||
| // Protect single-quoted strings (including multi-line) - simpler regex | ||
| protectedCommand = protectedCommand.replace(/'[^']*'/gs, (match) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these regexes do not have any escape support, so when you have a commit message with quotes in it you will again get garbled commands in the auto-allow list, for instance, take this git commit
git commit -m "refactor: \"In the garden of configuration, where validation blooms twice\"
Like Borges' labyrinth of forking paths, we've discovered that environment
validation had wandered into duplicate territories. The drizzle.ts file now
bears witness to this repetition—a mirror reflecting its own constraints,
where POSTGRES_URL and its companions are validated not once, but twice,
creating an echo chamber of certainty.
Meanwhile, in email.ts, the OrganizationInviteEmailData type has become
a palimpsest, its definition inscribed twice upon the parchment of code,
separated by empty lines that whisper of copy-paste's gentle touch.
As Hemingway might say: \"The code was good. Then it wasn't. Then it was
the same code twice.\" We've added statement_timeout to the pool config—
a temporal guardian standing watch over queries that might otherwise
wander too long in database dreams.
This commit captures a moment of duplication, a snapshot of code's
tendency toward repetition, like Gertrude Stein's \"a rose is a rose
is a rose\"—except here, it's validation that validates the validation."
We get
|
I really like the visual changes! I do think that the sanitation itself is more limited than my version, and think this still show the problematic behaviour in commits with quotes |
Fixes the issue where multi-line git commit messages were being incorrectly split into separate commands, causing cluttered UI in the auto-approved commands list.
Problem
Multi-line commands with quoted strings (like git commit messages) were being split at newline boundaries, even when those newlines were inside quotes. This caused:
Solution
Combined two fixes for a robust solution:
1. Root Cause Fix in parseCommand
parseCommandto protect quoted strings before splitting on newlines2. UI Display Fix in CommandExecution
Key Changes
parseCommandto handle quoted multi-line strings correctlyScreenshots
Before:


After:
Result
✅ Multi-line commands are properly validated (no incorrect splitting)
✅ UI shows clean, useful patterns (no unwieldy multi-line text)
✅ All existing functionality preserved
✅ All tests pass
Important
Fixes multi-line command parsing and UI display for quoted strings, enhancing
parseCommandand filtering multi-line patterns inCommandExecution.tsx.parseCommandto handle quoted strings correctly, preventing incorrect splitting.CommandExecution.tsx.CommandExecution.spec.tsxandcommand-validation.spec.tsto cover new parsing logic and UI behavior.command-validation.tsto preserve quoted content during parsing.This description was created by
for 6b69e79. You can customize this summary. It will automatically update as commits are pushed.